<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/11/27
 * Time: 16:48
 */

namespace app\api\model;


class Banner extends BaseModel
{
    protected $hidden = ['id','delete_time', 'update_time'];

    // 一对多
    // 一个banner有多个bannerItem，一个bannerItem只属于一个banner
    public function items()
    {
        return $this->hasMany('BannerItem', 'banner_id', 'id');
    }

    public static function getBannerByID($id)
    {
        return self::with(['items', 'items.image'])->find($id);
    }
}